import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;

/**
* @description: 1403. 非递增顺序的最小子序列
* @author hewei
* @date 2022/8/4 14:15
* @version 1.0
*/

public class MinSubsequence {

    public List<Integer> minSubsequence(int[] nums) {
        PriorityQueue<Integer> heap = new PriorityQueue<>((a, b) -> nums[b] - nums[a]);
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            heap.add(i);
            sum += nums[i];
        }
        List<Integer> ans = new ArrayList<>();
        int temp = 0;
        while (temp + temp <= sum) {
            Integer poll = heap.poll();
            temp += nums[poll];
            ans.add(nums[poll]);
        }
        return ans;
    }
}
